package com.compass.doctor.ui.mine.adapter

import android.annotation.SuppressLint
import android.graphics.drawable.Drawable
import android.view.LayoutInflater
import android.view.ViewGroup
import com.compass.doctor.R
import com.compass.doctor.callback.OnCustomButtonClick
import com.compass.doctor.databinding.LayoutUsefulExpressionsBinding

import com.compass.framework.adapter.BaseBindViewHolder
import com.compass.framework.adapter.BaseRecyclerViewAdapter
import com.compass.framework.constant.UsefulTypeOpeEnum
import com.compass.framework.ext.gone
import com.compass.framework.ext.onClick
import com.compass.framework.ext.visible
import com.compass.framework.model.UsefulExpressions

/**
 * Description： 常用语分类adapter
 * Date:2024/6/21 15:49
 */
class UsefulExpressionsAdapter :
    BaseRecyclerViewAdapter<UsefulExpressions, LayoutUsefulExpressionsBinding>() {
    override fun onBindDefViewHolder(
        holder: BaseBindViewHolder<LayoutUsefulExpressionsBinding>,
        item: UsefulExpressions?,
        position: Int
    ) {
        if (item == null) return
        holder.binding.apply {
            tvName.text = "${position+1}.${item.content}"
            if(mType == UsefulTypeOpeEnum.DELETE){
                //删除
                ivStatus.visible()
            }else{
                //查询
                ivStatus.gone()
            }
            if(item.selectStatus){
                ivStatus.setImageResource(R.mipmap.ic_agreement_select)
            }else{
                ivStatus.setImageResource(R.mipmap.ic_agreement_default)
            }
        }
    }
    private var mType :UsefulTypeOpeEnum = UsefulTypeOpeEnum.LIST;

    fun setmType(type : UsefulTypeOpeEnum) {
        this.mType = type
        notifyDataSetChanged()
    }

    fun getmType():UsefulTypeOpeEnum {
        return this.mType
    }

    fun getChooseCateIds(): String {
        var listIds = ArrayList<String?>()
        val list = getData()
        list.let {
            for (item in list) {
                if(item.selectStatus) listIds.add(item.id)
            }
        }
        return listIds.joinToString(separator = ",")
    }
    override fun getViewBinding(
        layoutInflater: LayoutInflater,
        parent: ViewGroup,
        viewType: Int
    ): LayoutUsefulExpressionsBinding {
        return LayoutUsefulExpressionsBinding.inflate(layoutInflater, parent, false)
    }
}